package 图形界面;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class UpFixGrid {
    //图七框架
    private JFrame frame7=new JFrame("报修");
    private JLabel StudentInfor=new JLabel("报修人");
    private JTextField StudentInfor1=new JTextField(80);
    private JLabel BuiltNum=new JLabel("宿舍几栋");
    private JTextField BuiltNum1=new JTextField(80);
    private JLabel DormNum=new JLabel("宿舍号");
    private JTextField DormNum1=new JTextField(80);
    private JLabel Reason=new JLabel("报修原因");
    private JTextField Reason1=new JTextField(80);
    private JButton but5=new JButton("提交");

    //图八框架
    private JFrame frame8=new JFrame();
    private JLabel m=new JLabel("已成功上传报修信息");
    public UpFixGrid() {
        frame7.setExtendedState(JFrame.MAXIMIZED_BOTH);
        frame7.setLayout(null);
        StudentInfor.setBounds(100, 60, 200, 20);
        StudentInfor1.setBounds(200, 60, 200, 20);
        BuiltNum.setBounds(100, 100, 200, 20);
        BuiltNum1.setBounds(200, 100, 200, 20);
        DormNum.setBounds(100, 140, 200, 20);
        DormNum1.setBounds(200, 140, 200, 20);
        Reason.setBounds(100, 180, 200, 20);
        Reason1.setBounds(200, 180, 200, 20);
        but5.setBounds(100, 220, 100, 20);
        frame7.add(StudentInfor);
        frame7.add(StudentInfor1);
        frame7.add(BuiltNum);
        frame7.add(BuiltNum1);
        frame7.add(DormNum);
        frame7.add(DormNum1);
        frame7.add(Reason);
        frame7.add(Reason1);
        frame7.add(but5);
        frame7.setVisible(true);
        but5.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                frame7.setVisible(false);
                String a = StudentInfor1.getText();
                int b = Integer.parseInt(BuiltNum1.getText());
                String c = DormNum1.getText();
                String d = Reason1.getText();
                try {
                    JDBC1.save2(a, b, c, d);
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
                frame7.setVisible(false);
                frame8.setSize(550, 400);
                frame8.setLocation(500, 200);
                frame8.setLayout(new FlowLayout());
                m.setBounds(100, 60, 200, 20);
                frame8.add(m);
                frame8.setVisible(true);
                frame8.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        });
        frame7.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
